//
//  ReportGuestHeadView.m
//  mendianjieke
//
//  Created by 响当当 on 11/4/19.
//  Copyright © 2019 dongzheng. All rights reserved.
//

#import "ReportGuestHeadView.h"
#import "BrokenLineBackView.h"

@interface ReportGuestHeadView()
@property (nonatomic, strong)UILabel *myDealMoneyLabel;
@property (nonatomic, strong)UILabel *myLastdayLabel;
@property (nonatomic, strong)UILabel *mySaleLabel;

@property (nonatomic, strong)UILabel *AllDealMoneyLabel;
@property (nonatomic, strong)UILabel *AllLastdayLabel;
@property (nonatomic, strong)UILabel *AllSaleLabel;

@property (nonatomic, strong)UIImageView *myRowImageView;
@property (nonatomic, strong)UIImageView *AllRowImageView;

@property (nonatomic, strong)UIView *headView;
@property (strong, nonatomic) BrokenLineBackView *brokenLineBackView;
@end

@implementation ReportGuestHeadView

- (UILabel *)myDealMoneyLabel
{
    if (!_myDealMoneyLabel)
    {
        UILabel *tagLabel = [Utilties creatLabelWithFrame:CGRectMake(0,15*kUIScaleBasePlus,15*kUIScaleBasePlus,31*kUIScaleBasePlus)
                                                    textAligment:NSTextAlignmentCenter
                                                        textClor:LCHexColor(0xFFFFFF)
                                                        textFont:10*kUIScaleBasePlus];
               tagLabel.backgroundColor = LCHexColor(0x198DF0);
               tagLabel.numberOfLines = 0;
               tagLabel.text = @"我\n的";
               [self addSubview:tagLabel];
               
               _myDealMoneyLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(tagLabel.frame),15*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                    textAligment:NSTextAlignmentCenter
                                                                  textClor:LCHexColor(0x3A3A3A)
                                                                  textFont:22*kUIScaleBasePlus];
               
                UILabel *saleLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(tagLabel.frame),CGRectGetMaxY(_myDealMoneyLabel.frame)+10*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                                textAligment:NSTextAlignmentCenter
                                                                    textClor:LCHexColor(0x484848)
                                                                    textFont:12*kUIScaleBasePlus];
                   saleLabel.text = @"服务人数";
                   [self addSubview:saleLabel];
               
        
    }
    return _myDealMoneyLabel;
}

- (UILabel *)myLastdayLabel
{
    if (!_myLastdayLabel)
    {
        _myLastdayLabel = [Utilties           creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-62.5*kUIScaleBasePlus,15*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                           textClor:LCHexColor(0x3A3A3A)
                                                           textFont:22*kUIScaleBasePlus];
        
         UILabel *saleLabel = [Utilties           creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-62.5*kUIScaleBasePlus,CGRectGetMaxY(_myDealMoneyLabel.frame)+10*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                         textAligment:NSTextAlignmentCenter
                                                             textClor:LCHexColor(0x484848)
                                                             textFont:12*kUIScaleBasePlus];
            saleLabel.text = @"较昨日";
            [self addSubview:saleLabel];
    }
    return _myLastdayLabel;
}

- (UILabel *)mySaleLabel
{
    if (!_mySaleLabel)
    {
        _mySaleLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.myLastdayLabel.frame),15*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                           textClor:LCHexColor(0x3A3A3A)
                                                           textFont:22*kUIScaleBasePlus];
        
         UILabel *saleLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.myLastdayLabel.frame),CGRectGetMaxY(_myDealMoneyLabel.frame)+10*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                         textAligment:NSTextAlignmentCenter
                                                             textClor:LCHexColor(0x484848)
                                                             textFont:12*kUIScaleBasePlus];
            saleLabel.text = @"占全店";
            [self addSubview:saleLabel];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(20*kUIScaleBasePlus,CGRectGetMaxY(saleLabel.frame)+14.5*kUIScaleBasePlus,335*kUIScaleBasePlus,0.5*kUIScaleBasePlus)];
        lineView.backgroundColor = JSALineColor;
        [self addSubview:lineView];
    }
    return _mySaleLabel;
}


- (UILabel *)AllDealMoneyLabel
{
    if (!_AllDealMoneyLabel)
    {
        UILabel *tagLabel = [Utilties creatLabelWithFrame:CGRectMake(0,CGRectGetMaxY(self.myDealMoneyLabel.frame)+59*kUIScaleBasePlus,15*kUIScaleBasePlus,31*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                 textClor:LCHexColor(0xFFFFFF)
                                                 textFont:10*kUIScaleBasePlus];
        tagLabel.backgroundColor = LCHexColor(0xF48B65);
        tagLabel.text = @"全\n店";
        tagLabel.numberOfLines = 0;
        [self addSubview:tagLabel];
        
        _AllDealMoneyLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(tagLabel.frame),CGRectGetMaxY(self.myDealMoneyLabel.frame)+58*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                             textAligment:NSTextAlignmentCenter
                                                           textClor:LCHexColor(0x3A3A3A)
                                                           textFont:22*kUIScaleBasePlus];
        
         UILabel *saleLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(tagLabel.frame),CGRectGetMaxY(_AllDealMoneyLabel.frame)+10*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                         textAligment:NSTextAlignmentCenter
                                                             textClor:LCHexColor(0x484848)
                                                             textFont:12*kUIScaleBasePlus];
            saleLabel.text = @"客流";
            [self addSubview:saleLabel];
        
    }
    return _AllDealMoneyLabel;
}

- (UILabel *)AllLastdayLabel
{
    if (!_AllLastdayLabel)
    {
        _AllLastdayLabel = [Utilties           creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-62.5*kUIScaleBasePlus,CGRectGetMaxY(self.myDealMoneyLabel.frame)+58*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                     textAligment:NSTextAlignmentCenter
                                                         textClor:LCHexColor(0x3A3A3A)
                                                         textFont:22*kUIScaleBasePlus];
        
          UILabel *saleLabel = [Utilties           creatLabelWithFrame:CGRectMake(SCREEN_WIDTH/2-62.5*kUIScaleBasePlus,CGRectGetMaxY(_AllDealMoneyLabel.frame)+10*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                                 textAligment:NSTextAlignmentCenter
                                                                     textClor:LCHexColor(0x484848)
                                                                     textFont:12*kUIScaleBasePlus];
            saleLabel.text = @"较昨日";
            [self addSubview:saleLabel];
    }
    return _AllLastdayLabel;
}

- (UILabel *)AllSaleLabel
{
    if (!_AllSaleLabel)
    {
        _AllSaleLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.AllLastdayLabel.frame),CGRectGetMaxY(self.myDealMoneyLabel.frame)+58*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                  textAligment:NSTextAlignmentCenter
                                                      textClor:LCHexColor(0x3A3A3A)
                                                      textFont:22*kUIScaleBasePlus];
        
         UILabel *saleLabel = [Utilties           creatLabelWithFrame:CGRectMake(CGRectGetMaxX(self.AllLastdayLabel.frame),CGRectGetMaxY(_AllDealMoneyLabel.frame)+10*kUIScaleBasePlus,125*kUIScaleBasePlus,16.5*kUIScaleBasePlus)
                                                         textAligment:NSTextAlignmentCenter
                                                             textClor:LCHexColor(0x484848)
                                                             textFont:12*kUIScaleBasePlus];
            saleLabel.text = @"日均客流";
            [self addSubview:saleLabel];
        
        UIView *myView = [[UIView alloc]initWithFrame:CGRectMake(31.5*kUIScaleBasePlus,CGRectGetMaxY(saleLabel.frame)+12*kUIScaleBasePlus,6*kUIScaleBasePlus,6*kUIScaleBasePlus)];
              myView.backgroundColor = ThemeColor;
              [self addSubview:myView];
              
              UILabel *myLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(myView.frame)+3*kUIScaleBasePlus,CGRectGetMaxY(saleLabel.frame)+10*kUIScaleBasePlus,30*kUIScaleBasePlus,10*kUIScaleBasePlus) textAligment:NSTextAlignmentLeft textClor:LCHexColor(0x979797) textFont:10*kUIScaleBasePlus];
              myLabel.text = @"我的";
              [self addSubview:myLabel];
              
              
              UIView *AllView = [[UIView alloc]initWithFrame:CGRectMake(CGRectGetMaxX(myLabel.frame)+16.5*kUIScaleBasePlus,CGRectGetMaxY(saleLabel.frame)+12*kUIScaleBasePlus,6*kUIScaleBasePlus,6*kUIScaleBasePlus)];
                    AllView.backgroundColor = YellowColor;
                    [self addSubview:AllView];
              
              UILabel *allLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(AllView.frame)+3*kUIScaleBasePlus,CGRectGetMaxY(saleLabel.frame)+10*kUIScaleBasePlus,30*kUIScaleBasePlus,10*kUIScaleBasePlus) textAligment:NSTextAlignmentLeft textClor:LCHexColor(0x979797) textFont:10*kUIScaleBasePlus];
                    allLabel.text = @"全店";
                    [self addSubview:allLabel];
              
    }
    return _AllSaleLabel;
}

- (UIView *)headView
{
    if (!_headView)
    {
        _headView = [[UIView alloc]initWithFrame:CGRectMake(0,380*kUIScaleBasePlus,SCREEN_WIDTH,104*kUIScaleBasePlus)];
        _headView.backgroundColor = [UIColor whiteColor];
        
        UIView *lineView = [[UIView alloc]initWithFrame:CGRectMake(0,0,SCREEN_WIDTH,10*kUIScaleBasePlus)];
        lineView.backgroundColor = LCHexColor(0xEDEDED);
        [_headView addSubview:lineView];
        
        UIView *verLineView = [[UIView alloc]initWithFrame:CGRectMake(15*kUIScaleBasePlus,28*kUIScaleBasePlus,3*kUIScaleBasePlus,15*kUIScaleBasePlus)];
        verLineView.backgroundColor = LCHexColor(0xFF7A17);
        verLineView.layer.masksToBounds = YES;
        verLineView.layer.cornerRadius = verLineView.frame.size.width/2;
        [_headView addSubview:verLineView];
        
        UILabel *titleLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(verLineView.frame)+5*kUIScaleBasePlus,25*kUIScaleBasePlus,80*kUIScaleBasePlus,21*kUIScaleBasePlus)
                                               textAligment:NSTextAlignmentLeft
                                                   textClor:LCHexColor(0x282828)
                                                   textFont:15*kUIScaleBasePlus];
        titleLabel.text = @"访客列表";
        [_headView addSubview:titleLabel];
        
        UIButton *rowButton = [Utilties creatButtonWithFrame:CGRectMake(353*kUIScaleBasePlus,29*kUIScaleBasePlus,6*kUIScaleBasePlus,12*kUIScaleBasePlus)
                                                textAligment:UIControlContentHorizontalAlignmentCenter
                                                        text:@""
                                                    textClor:nil
                                                   buttonBGC:[UIColor clearColor]
                                                    textFont:10
                                                      target:self method:@selector(gotoWhere)];
        [rowButton setImage:[UIImage imageNamed:@"liebiaogengduo"] forState:UIControlStateNormal];
        [_headView addSubview:rowButton];
        
        UIView *blineView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(rowButton.frame)+12*kUIScaleBasePlus,SCREEN_WIDTH,0.5*kUIScaleBasePlus)];
        blineView.backgroundColor = JSALineColor;
        [_headView addSubview:blineView];
        
        UILabel *nameLabel = [Utilties creatLabelWithFrame:CGRectMake(15*kUIScaleBasePlus,CGRectGetMaxY(blineView.frame)+10*kUIScaleBasePlus,52*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                              textAligment:NSTextAlignmentCenter
                                                  textClor:LCHexColor(0x8B8B8B)
                                                  textFont:12*kUIScaleBasePlus];
        nameLabel.text = @"客户性别";
        [_headView addSubview:nameLabel];
        
        UILabel *ageLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(nameLabel.frame)+20*kUIScaleBasePlus,CGRectGetMaxY(blineView.frame)+10*kUIScaleBasePlus,52*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                                     textAligment:NSTextAlignmentCenter
                                                         textClor:LCHexColor(0x8B8B8B)
                                                         textFont:12*kUIScaleBasePlus];
               ageLabel.text = @"客户年龄";
               [_headView addSubview:ageLabel];
        
        UILabel *timeLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(ageLabel.frame)+55.5*kUIScaleBasePlus,CGRectGetMaxY(blineView.frame)+10*kUIScaleBasePlus,52*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                                     textAligment:NSTextAlignmentCenter
                                                         textClor:LCHexColor(0x8B8B8B)
                                                         textFont:12*kUIScaleBasePlus];
               timeLabel.text = @"访问时间";
               [_headView addSubview:timeLabel];
        
        UILabel *dealLabel = [Utilties creatLabelWithFrame:CGRectMake(CGRectGetMaxX(timeLabel.frame)+61.5*kUIScaleBasePlus,CGRectGetMaxY(blineView.frame)+10*kUIScaleBasePlus,52*kUIScaleBasePlus,18.5*kUIScaleBasePlus)
                                                     textAligment:NSTextAlignmentCenter
                                                         textClor:LCHexColor(0x8B8B8B)
                                                         textFont:12*kUIScaleBasePlus];
               dealLabel.text = @"成交状态";
               [_headView addSubview:dealLabel];
        
        UIView *llineView = [[UIView alloc]initWithFrame:CGRectMake(0,CGRectGetMaxY(dealLabel.frame)+7.5*kUIScaleBasePlus,SCREEN_WIDTH,0.5*kUIScaleBasePlus)];
        llineView.backgroundColor = JSALineColor;
        [_headView addSubview:llineView];
    }
    
    return _headView;
}


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self)
    {
        [self addSubview:self.myDealMoneyLabel];
        [self addSubview:self.myLastdayLabel];
        [self addSubview:self.mySaleLabel];
        [self addSubview:self.AllDealMoneyLabel];
        [self addSubview:self.AllLastdayLabel];
        [self addSubview:self.AllSaleLabel];
        [self addSubview:self.brokenLineBackView];
        [self addSubview:self.headView];
    }
    return self;
}

- (void)gotoWhere
{
    
}

#pragma mark - 获取数据
- (void)getInfo:(ReportLineModel *)model
{
    
    if (self.brokenLineBackView)
    {
        [self.brokenLineBackView removeFromSuperview];
    }
    
    NSMutableArray *numArr = [[NSMutableArray alloc]init];
    NSMutableArray *myNumArr = [[NSMutableArray alloc]init];
    NSMutableArray *allNumArr = [[NSMutableArray alloc]init];
    NSMutableArray *dataArr = [[NSMutableArray alloc]init];
    NSMutableArray *myArr = [[NSMutableArray alloc]init];//我的数据
    NSMutableArray *allArr = [[NSMutableArray alloc]init];//所有的数据
    
    NSDictionary *myDic = [[NSDictionary alloc]initWithDictionary:model.mydata];
    
    NSDictionary *AllDic = [[NSDictionary alloc]initWithDictionary:model.alldata];

    for (int i=0; i<model.myChartArr.count; i++)
    {
        NSDictionary *dic = model.myChartArr[i];
        NSNumber *num = dic[@"number"];
        [numArr addObject:num];
        [dataArr addObject:dic[@"date"]];
    }
   
    for (int i=0; i<model.allChartArr.count; i++)
      {
          NSDictionary *dic = model.allChartArr[i];
          NSNumber *num = dic[@"number"];
          [numArr addObject:num];
      }
    
    NSMutableArray *NewNumArr = [[NSMutableArray alloc]init];
    NewNumArr = [Utilties BubbleSorting:[numArr isValidArray] ? numArr : [NSMutableArray arrayWithArray:@[@"100",@"200",@"50",@"65",@"30",@"1",@"10"]]];
    
    CGFloat times = ([[numArr lastObject] integerValue])/132.0;

    for (int i=0; i<model.myChartArr.count; i++)
       {
           NSDictionary *dic = model.myChartArr[i];
           NSNumber *num = dic[@"number"];
           [myArr addObject:num.stringValue];
           [myNumArr addObject:[NSString stringWithFormat:@"%.f",(200-23-num.floatValue/times)*kUIScaleBasePlus]];
       }
      
       for (int i=0; i<model.allChartArr.count; i++)
         {
             NSDictionary *dic = model.allChartArr[i];
             NSNumber *num = dic[@"number"];
             [allArr addObject:num.stringValue];
             [allNumArr addObject:[NSString stringWithFormat:@"%.f",(200-23-num.floatValue/times)*kUIScaleBasePlus]];

         }
    
    
    
    self.brokenLineBackView = [BrokenLineBackView foundBrokenLineChartXNodeAry:dataArr yNodeAry:@[@"人",[NSString stringWithFormat:@"%ld",(long)[[numArr lastObject] integerValue]], [NSString stringWithFormat:@"%.f",(132*3)/4*times], [NSString stringWithFormat:@"%.f",(132*2)/4*times], [NSString stringWithFormat:@"%.f",(132*1)/4*times]] xOrigin:40*kUIScaleBasePlus yOrigin:25*kUIScaleBasePlus xAxisSpac:46*kUIScaleBasePlus yAxisSpac:33*kUIScaleBasePlus xAxisRightSpac:10*kUIScaleBasePlus yAxisTopSpac:10*kUIScaleBasePlus];
    [self addSubview:self.brokenLineBackView];

    self.brokenLineBackView.frame = CGRectMake(10*kUIScaleBasePlus,CGRectGetMaxY(self.AllSaleLabel.frame)+50*kUIScaleBasePlus,SCREEN_WIDTH-40*kUIScaleBasePlus,200*kUIScaleBasePlus);
    self.brokenLineBackView.brokenScrollView.scrollEnabled = NO;
    self.brokenLineBackView.brokenScrollView.brokenLineView.brokenLineColorAry = @[ThemeColor, YellowColor];
 
    self.brokenLineBackView.brokenScrollView.brokenLineView.brokenLineAry = @[myNumArr, allNumArr];
    self.brokenLineBackView.brokenScrollView.brokenLineView.lineArr = @[allArr, myArr];
    
    NSString *myDealStr = [NSString stringWithFormat:@"%@%@",myDic[@"passengerFlow"],@"人"];
    NSString *purchaseStr = [NSString stringWithFormat:@"%@%@",myDic[@"proportion"],@"%"];
    
    NSString *myNum = [NSString stringWithFormat:@"%@",myDic[@"contrast"]];
       
    NSString *contrastStr = [NSString stringWithFormat:@"%ld%@",myNum.integerValue <0 ? -1*myNum.integerValue : myNum.integerValue,@"%"];

    self.myDealMoneyLabel.attributedText = [myDealStr addAttriButedString:myDealStr Color:LCHexColor(0x484848) Font:[UIFont systemFontOfSize:12*kUIScaleBasePlus] rang:NSMakeRange(myDealStr.length-1,1)];
    
    
     if (myNum.integerValue < 0)
        {
            self.myLastdayLabel.textColor = LCHexColor(0x21AA50);
            NSMutableAttributedString *goalTipStr = [[NSMutableAttributedString alloc]initWithString:contrastStr];
            NSTextAttachment *alertImg = [[NSTextAttachment alloc]init];
            alertImg.image = [UIImage imageNamed:@"parameter_down"];
            alertImg.bounds=CGRectMake(-5*kUIScaleBasePlus,3*kUIScaleBasePlus,6*kUIScaleBasePlus,7*kUIScaleBasePlus);
            NSAttributedString *imgStr = [NSAttributedString attributedStringWithAttachment:alertImg];
            [goalTipStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12*kUIScaleBasePlus] range:NSMakeRange(contrastStr.length-1,1)];
            [goalTipStr insertAttributedString:imgStr atIndex:0];
     
            self.myLastdayLabel.attributedText = goalTipStr;
        }
        else
        {
            self.myLastdayLabel.textColor = LCHexColor(0xFF4949);
            NSMutableAttributedString *goalTipStr = [[NSMutableAttributedString alloc]initWithString:contrastStr];
            NSTextAttachment *alertImg = [[NSTextAttachment alloc]init];
            alertImg.image = [UIImage imageNamed:@"parameter_up"];
        alertImg.bounds=CGRectMake(-5*kUIScaleBasePlus,3*kUIScaleBasePlus,6*kUIScaleBasePlus,7*kUIScaleBasePlus);
            NSAttributedString *imgStr = [NSAttributedString attributedStringWithAttachment:alertImg];
            [goalTipStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12*kUIScaleBasePlus] range:NSMakeRange(contrastStr.length-1,1)];
            [goalTipStr insertAttributedString:imgStr atIndex:0];
            self.myLastdayLabel.attributedText = goalTipStr;
        }
    
    self.mySaleLabel.attributedText = [purchaseStr addAttriButedString:purchaseStr Color:LCHexColor(0x484848) Font:[UIFont systemFontOfSize:12*kUIScaleBasePlus] rang:NSMakeRange(purchaseStr.length-1,1)];
    
    
    NSString *allDealStr = [NSString stringWithFormat:@"%@人",AllDic[@"passengerFlow"]];
    NSString *allpurchaseStr = [NSString stringWithFormat:@"%@%@",AllDic[@"average"],@"人"];
    NSString *allNum = [NSString stringWithFormat:@"%@",AllDic[@"contrast"]];
    NSString *allcontrastStr = [NSString stringWithFormat:@"%ld%@",allNum.integerValue <0 ? -1*allNum.integerValue : allNum.integerValue,@"%"];

    self.AllDealMoneyLabel.attributedText = [allDealStr addAttriButedString:allDealStr Color:LCHexColor(0x484848) Font:[UIFont systemFontOfSize:12*kUIScaleBasePlus] rang:NSMakeRange(allDealStr.length-1,1)];
      


     if (allNum.integerValue < 0)
       {
           self.AllLastdayLabel.textColor = LCHexColor(0x21AA50);
           NSMutableAttributedString *goalTipStr = [[NSMutableAttributedString alloc]initWithString:allcontrastStr];
           NSTextAttachment *alertImg = [[NSTextAttachment alloc]init];
           alertImg.image = [UIImage imageNamed:@"parameter_down"];
       alertImg.bounds=CGRectMake(-5*kUIScaleBasePlus,3*kUIScaleBasePlus,6*kUIScaleBasePlus,7*kUIScaleBasePlus);
           NSAttributedString *imgStr = [NSAttributedString attributedStringWithAttachment:alertImg];
           [goalTipStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12*kUIScaleBasePlus] range:NSMakeRange(allcontrastStr.length-1,1)];
           [goalTipStr insertAttributedString:imgStr atIndex:0];
           self.AllLastdayLabel.attributedText = goalTipStr;
       }
       else
       {
           self.AllLastdayLabel.textColor = LCHexColor(0xFF4949);
           NSMutableAttributedString *goalTipStr = [[NSMutableAttributedString alloc]initWithString:allcontrastStr];
           NSTextAttachment *alertImg = [[NSTextAttachment alloc]init];
           alertImg.image = [UIImage imageNamed:@"parameter_up"];
       alertImg.bounds=CGRectMake(-5*kUIScaleBasePlus,3*kUIScaleBasePlus,6*kUIScaleBasePlus,7*kUIScaleBasePlus);
           NSAttributedString *imgStr = [NSAttributedString attributedStringWithAttachment:alertImg];
           [goalTipStr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:12*kUIScaleBasePlus] range:NSMakeRange(allcontrastStr.length-1,1)];
           [goalTipStr insertAttributedString:imgStr atIndex:0];
           self.AllLastdayLabel.attributedText = goalTipStr;

       }
      
      self.AllSaleLabel.attributedText = [allpurchaseStr addAttriButedString:allpurchaseStr Color:LCHexColor(0x484848) Font:[UIFont systemFontOfSize:12*kUIScaleBasePlus] rang:NSMakeRange(allpurchaseStr.length-1,1)];
    
}


@end

